<template>
  <div>
    <h1>注册and登录页面</h1>
    <p>注册账号：<input type="text" v-model="form.username"></p>
    <p>注册密码：<input type="text" v-model="form.password"></p>
    <button @click="zc">确认注册</button>
    <p>登录账号：<input type="text" v-model="aaa.username"></p>
    <p>登录密码：<input type="text" v-model="aaa.password"></p>
    <button @click="dl">确认登录</button>
  </div>
</template>

<script>
export default {
  name: "zcanddl",
  data() {
    return {
      form: {},
      aaa:{}
    }
  },
  methods: {
    zc() {
      this.$axios.post('users/ZcMAPI/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('注册成功')
            this.form = {}
          } else {
            alert('注测失败')
          }
        })
    },
    dl() {
      this.$axios.post('users/DlMAPI/', this.aaa)
        .then(res => {
          if (res.data.code == 200) {
            alert('登录成功')
            localStorage.setItem('usersid',res.data.usersid)
            this.$router.push({path:'/shopm'})
          } else {
            alert('登录失败')
          }
        })
    }
  }
}
</script>

<style scoped>

</style>
